# 使用官方的Ubuntu基础镜像
FROM ubuntu:20.04


# 更新软件包列表并安装必要的依赖 squashfs-tools-ng
RUN apt-get update && apt-get upgrade -y && apt-get install sudo
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN sudo apt-get install -y -qq \  
    net-tools \
    dos2unix \
    vim \
    curl \
    tzdata \
    build-essential \
    libssl-dev \
    uuid-dev \  
    libudev-dev \ 
    libgpgme-dev \    
    squashfs-tools \    
    libseccomp-dev \    
    wget \    
    pkg-config \    
    git \    
    cryptsetup-bin && \    
    apt-get clean && \
    rm -rf /tmp/* /var/cache/* /usr/share/doc/* /usr/share/man/* /var/lib/apt/lists/*

# 进入usr/local
WORKDIR /usr/local

# 安装go1.14.12
RUN export VERSION=1.14.12 OS=linux ARCH=amd64 && \  
    wget https://dl.google.com/go/go$VERSION.$OS-$ARCH.tar.gz && \ 
    tar -xzvf go$VERSION.$OS-$ARCH.tar.gz && \ 
    rm go$VERSION.$OS-$ARCH.tar.gz

# 配置go PATH
ENV GOPATH /go
ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
# ENV GOPROXY=https://goproxy.cn

# 下载 singularity脚本 https://github.com/sylabs/singularity.git
RUN git clone https://gitclone.com/github.com/sylabs/singularity.git && \    
    cd singularity && \    
    git checkout v3.7.1

# singularity
WORKDIR /usr/local/singularity

# 编译前修改makefile使用的 goPath
RUN sed -i '$i\GOPROXY := https:\/\/goproxy.cn' mlocal/frags/go_common_opts.mk

# 编译singularity
RUN ./mconfig && \    
    make -C ./builddir && \    
    sudo make -C ./builddir install

# 设置工作目录
WORKDIR /home/zl

# 将当前目录下的所有文件复制到工作目录
COPY . /home/zl

